<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script crossorigin="anonymous" src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
</head>

<body>
    <button>GET</button>
    <button>POST</button>
    <button>AJAX</button>
    <script>
        const btns = document.querySelectorAll('button');
        btns[0].onclick = function() {
            axios.get('http://127.0.0.1:8080/axios-server', {
                //URL参数
                params: {
                    id: 100,
                    vip: 7
                },
                //请求头信息
                headers: {
                    name: 'wzc',
                    age: '20'
                }
            }).then(value => {
                console.log(value);
            })
        }
        btns[1].onclick = function() {
            axios.post('http://127.0.0.1:8080/axios-server', {
                username: 'abc',
                password: 'admin'
            }, {
                //url
                params: {
                    id: 200,
                    vip: 3
                },
                headers: {
                    height: 100,
                    weight: 180
                }
            })
        }
        btns[2].onclick = function() {
            axios({
                method: 'POST',
                url: 'http://127.0.0.1:8080/axios-server',
                params: {
                    vip: 10,
                    level: 30
                },
                headers: {
                    a: 100,
                    b: 200
                },
                data: {
                    username: "wzc",
                    password: '123456'
                }
            }).then(data => {
                console.log(data);
            })
        }
    </script>
</body>

</html>